package wjh.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;
import wjh.pojo.Admin;
import wjh.pojo.Num;
import wjh.pojo.Plan;
import wjh.pojo.Sex;

import java.util.HashMap;
import java.util.List;

@Repository
public interface AdminMapper {
    @Select("select * from admin where username=#{username} and password=#{password}")
    Admin login(Admin admin);

    @Select("SELECT DISTINCT r.department AS 'name',COUNT(*) AS 'num'\n" +
            "FROM reports r GROUP BY r.department")
    List<Num> echarts();
    @Select("SELECT DISTINCT p.sex AS 'name',COUNT(*) AS 'num'\n" +
            "FROM patient p GROUP BY p.sex")
    List<Sex> echarts2();

    @Insert("INSERT INTO plan VALUES(NULL,#{doctor_id},#{number},#{week})")
    void addPaiBan(Plan plan);

    @Update("update plan set doctor_id=#{doctor_id},number=#{number},week=#{week} where id=#{id}")
    void updatePaiBan(Plan plan);

    @Select("SELECT age FROM patient")
    List<Integer> findAllAges();
}
